


//
//  ZInviteViewController.m
//  ZQLearn
//
//  Created by macfeel on 2019/4/21.
//  Copyright © 2019 macfeel. All rights reserved.
//

#import "ZInviteViewController.h"
#import "WXApi.h"
@interface ZInviteViewController ()
@property (nonatomic ,strong) UIScrollView *bgScrollView;

@property (weak, nonatomic) IBOutlet UIView *bgView;

@property (weak, nonatomic) IBOutlet UIView *topView;

@property (weak, nonatomic) IBOutlet UIButton *activeBtn;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *activeBtnLeftMargin;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rightMargin;

@property (weak, nonatomic) IBOutlet UIImageView *wxBtn;

@property (weak, nonatomic) IBOutlet UIImageView *pyqBtn;

@property (weak, nonatomic) IBOutlet UIImageView *qqBtn;

@end

@implementation ZInviteViewController

- (UIScrollView *)bgScrollView{
    if (!_bgScrollView) {
        _bgScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        _bgScrollView.backgroundColor = [UIColor whiteColor];
        [_bgScrollView setScrollEnabled:YES];
        [_bgScrollView setShowsVerticalScrollIndicator:NO];
        
        _bgScrollView.contentSize = CGSizeMake(ScreenWidth, ScreenHeight+100);
    }
    return _bgScrollView;
}
/*
 
 1、邀请好友注册，好友注册成功，您与好友均可得300积分。
 2、邀请者发送APP的链接给受邀者，受邀者点击链接完成注册，即完成邀请。
 3、受邀者点击下载K15智秦学习APP，注册完成后，在APP内一次点击“我的”-“邀请有奖”-“我的邀请人”，在弹出的提示框内，填写邀请者的邀请码（手机号），即完成一次邀请。
 4、本次活动最终解释权归智秦数字出版有限责任公司所有。
 特别声明：我们包含邀请注册在内的所有优惠推广活动仅向正当、合法使用APP用户。所有用户需遵守《用户注册协议》的相关条款。
 */

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self.navigationItem setItemWithTitle:@"邀请有奖" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    self.activeBtn.layer.cornerRadius = 5.f;
    self.activeBtn.layer.masksToBounds = YES;
    self.activeBtn.backgroundColor = kSystemtBlue;
    self.topView.backgroundColor = kSystemtBlue;
    if (ScreenWidth<375) {
        self.activeBtnLeftMargin.constant = 5.f;
        self.rightMargin.constant = 15.f;
    }
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(wxAction:)];
    [self.wxBtn addGestureRecognizer:tap1];
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pyqAction:)];
    [self.pyqBtn addGestureRecognizer:tap2];
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(qqAction:)];
    [self.qqBtn addGestureRecognizer:tap3];
//    [self.bgScrollView addSubview:self.bgView];
//    [self.view addSubview:self.bgScrollView];
    // Do any additional setup after loading the view from its nib.
}
///
- (void)wxAction:(UITapGestureRecognizer *)tap
{
    ///需要替换具体分享内容
//    return;
    if([WXApi isWXAppInstalled]){//判断当前设备是否安装微信客户端
        
        //创建多媒体消息结构体
        WXMediaMessage *message = [WXMediaMessage message];
        message.title = @"邀请有奖";//标题
        message.description = @"您的邀请码OEPGM";//描述
        [message setThumbImage:[UIImage imageNamed:@"lpgo"]];//设置预览图
        
        //创建网页数据对象
        WXWebpageObject *webObj = [WXWebpageObject object];
        webObj.webpageUrl = @"http://sdxx.bestzhiqinweike.com/app/zqDownLoad";//链接
        message.mediaObject = webObj;
        
        SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
        sendReq.bText = NO;//不使用文本信息
        sendReq.message = message;
        
        ///分享方式，好友WXSceneSession，朋友圈WXSceneTimeline
        sendReq.scene = WXSceneSession;//分享到好友会话
        
        [WXApi sendReq:sendReq];//发送对象实例
        
    }else{
        
        //未安装微信应用或版本过低
        
    }

}
///
- (void)pyqAction:(UITapGestureRecognizer *)tap
{
    ///需要替换具体分享内容
    
    if([WXApi isWXAppInstalled]){//判断当前设备是否安装微信客户端
        
        //创建多媒体消息结构体
        WXMediaMessage *message = [WXMediaMessage message];
        message.title = @"邀请有奖";//标题
        message.description = @"您的邀请码OEPGM";//描述
        [message setThumbImage:[UIImage imageNamed:@"lpgo"]];//设置预览图
        
        //创建网页数据对象
        WXWebpageObject *webObj = [WXWebpageObject object];
        webObj.webpageUrl = @"http://sdxx.bestzhiqinweike.com/app/zqDownLoad";//链接
        message.mediaObject = webObj;
        
        SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
        sendReq.bText = NO;//不使用文本信息
        sendReq.message = message;
        
        ///分享方式，好友WXSceneSession，朋友圈WXSceneTimeline
        sendReq.scene = WXSceneTimeline;//分享到好友会话
        
        [WXApi sendReq:sendReq];//发送对象实例
        
    }else{
        
        //未安装微信应用或版本过低
        
    }
    
}


///
- (void)qqAction:(UITapGestureRecognizer *)tap
{
    YYLog(@"qq");
    
}

- (IBAction)activeBtnAction:(UIButton *)sender {
    
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [super touchesBegan:touches withEvent:event];
    [self.view endEditing:YES];

}


@end
